package org.ns.framework.datasource.config;

import org.ns.framework.datasource.anns.EnableDBDataSource;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ConditionDataSource implements Condition {

	@Override
	public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
		try {
			String[] xx = context.getBeanFactory().getBeanNamesForAnnotation(EnableDBDataSource.class);
			
			return xx.length > 0;
		} catch (Exception e) {
			
			System.out.println();
			
		}
//		Environment env = context.getEnvironment();
//		metadata.getAnnotationAttributes(null)
		return false;
	}

}
